<template>
  <el-dialog title="详细信息" :visible.sync="dialogVisible" class="dialog">
    <el-descriptions direction="vertical" :column="3" border>

      <el-descriptions-item label="昵称">{{ info.nickName }}</el-descriptions-item>
      <el-descriptions-item label="id">{{ info.id }}</el-descriptions-item>
      <el-descriptions-item label="头像">
        <img :src="info.avatar" style="width: 30px;height: 30px;border-radius: 50%;" alt="">
      </el-descriptions-item>
      <el-descriptions-item label="邮箱">{{ info.email }}</el-descriptions-item>
      <el-descriptions-item label="最后登录时间	">{{ info.lastLoginTime }}</el-descriptions-item>
      <el-descriptions-item label="邀请码	">{{ info.inviteCode }}</el-descriptions-item>
      <el-descriptions-item label="创建时间	">{{ info.createTime }}</el-descriptions-item>
      
      <el-descriptions-item label="是否封禁">{{ info.isEnable==1? '否':'是' }}</el-descriptions-item>

    
    </el-descriptions>

    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </span>
    <el-dialog
      width="30%"
      title="设置团队等级"
      :visible.sync="innerVisible"
      append-to-body
    >    <el-input v-model="rate" placeholder="团队等级" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="innerVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirm1">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      width="30%"
      title="设置上级"
      :visible.sync="innerVisible2"
      append-to-body
    >    <el-input v-model="inviteCode" placeholder="设置上级" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="innerVisible2 = false">取 消</el-button>
        <el-button type="primary" @click="confirm2">确 定</el-button>
      </span>
    </el-dialog>
  </el-dialog>
</template>
<script>
import { setTeamRate, setInviteUser } from '@/api/table'
export default {
  data() {
    return {
      innerVisible: false,
      dialogVisible: false,
      innerVisible2: false,
      info: {},
      rate: '',
      inviteCode: ''
    }
  },

  methods: {
    show(e) {
      this.info = e
      this.rate = this.info.userTeamRate
      this.inviteCode = this.info.inviteCode

      this.dialogVisible = true
    },
    confirm() {
      this.$parent.fetchData()
      this.dialogVisible = false
    },
    confirm1() {
      setTeamRate({ userId: this.info.id, rate: this.rate }).then(res => {
        if (res.code === 200) {
          this.innerVisible = false
          this.confirm()
          this.$message({
            message: '成功',
            type: 'success'
          })
        }
      })
    },
    confirm2() {
      setInviteUser({ userId: this.info.id, inviteCode: this.inviteCode }).then(res => {
        if (res.code === 200) {
          this.innerVisible2 = false
          this.confirm()

          this.$message({
            message: '成功',
            type: 'success'
          })
        }
      })
    }
  }
}
</script>
